package com.project.forlearningdemo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

//@Configuration
//@EnableSwagger2
public class SwaggerConfig {

    /**
     * 创建一个Docket 并且注册到Spring容器里即可完成配置
     *
     * @return Docket
     */
   // @Bean
    public Docket createRestApi_xg(Environment environment){

        return new Docket(DocumentationType.SWAGGER_2)
                .enable(true)
                .groupName("小黑2号")
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.project.forlearningdemo.controller"))
                .paths(PathSelectors.any())
                .build();
    }


    /**
     *   设置API信息 一些简单的描述信息而已
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("API Document for ForLearning")
                .description("为梦想而奋斗！")
                .contact(new Contact("for learning", "http://110.40.212.77:8088/forlearning", "1804859224@qq.com"))
                .version("1.0.0")
                .build();
    }

}
